package com.ruoyi.monitor.infoprojectmonitorindex.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.evaluate.infoprojectevaluate.domain.InfoProjectEvaluate;
import com.ruoyi.monitor.infoprojectmonitorindex.domain.InfoProjectMonitorIndex;
import com.ruoyi.monitor.infoprojectmonitorindex.mapper.InfoProjectMonitorIndexMapper;
import com.ruoyi.monitor.infoprojectmonitorindex.service.IInfoProjectMonitorIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 项目监控 -指标Service业务层处理
 *
 * @author ruoyi
 * @date 2022-02-15
 */
@Service
public class InfoProjectMonitorIndexServiceImpl implements IInfoProjectMonitorIndexService {
    @Autowired
    private InfoProjectMonitorIndexMapper infoProjectMonitorIndexMapper;

    /**
     * 查询项目监控 -指标
     *
     * @param id 项目监控 -指标主键
     * @return 项目监控 -指标
     */
    @Override
    public InfoProjectMonitorIndex selectInfoProjectMonitorIndexById(Long id) {
        return infoProjectMonitorIndexMapper.selectInfoProjectMonitorIndexById(id);
    }

    /**
     * 查询项目监控 -指标列表
     *
     * @param infoProjectMonitorIndex 项目监控 -指标
     * @return 项目监控 -指标
     */
    @Override
    public List<InfoProjectMonitorIndex> selectInfoProjectMonitorIndexList(InfoProjectMonitorIndex infoProjectMonitorIndex) {
        return infoProjectMonitorIndexMapper.selectInfoProjectMonitorIndexList(infoProjectMonitorIndex);
    }

    /**
     * 新增项目监控 -指标
     *
     * @param infoProjectMonitorIndex 项目监控 -指标
     * @return 结果
     */
    @Override
    public int insertInfoProjectMonitorIndex(InfoProjectMonitorIndex infoProjectMonitorIndex) {
        infoProjectMonitorIndex.setCreateTime(DateUtils.getNowDate());
        return infoProjectMonitorIndexMapper.insertInfoProjectMonitorIndex(infoProjectMonitorIndex);
    }

    /**
     * 修改项目监控 -指标
     *
     * @param infoProjectMonitorIndex 项目监控 -指标
     * @return 结果
     */
    @Override
    public int updateInfoProjectMonitorIndex(InfoProjectMonitorIndex infoProjectMonitorIndex) {
        infoProjectMonitorIndex.setUpdateTime(DateUtils.getNowDate());
        infoProjectMonitorIndex.setUpdateBy(SecurityUtils.getLoginUser().getUser().getDept().getDeptName() + "-" + SecurityUtils.getLoginUser().getUser().getNickName());
        return infoProjectMonitorIndexMapper.updateInfoProjectMonitorIndex(infoProjectMonitorIndex);
    }

    /**
     * 批量删除项目监控 -指标
     *
     * @param ids 需要删除的项目监控 -指标主键
     * @return 结果
     */
    @Override
    public int deleteInfoProjectMonitorIndexByIds(Long[] ids) {
        return infoProjectMonitorIndexMapper.deleteInfoProjectMonitorIndexByIds(ids);
    }

    /**
     * 删除项目监控 -指标信息
     *
     * @param id 项目监控 -指标主键
     * @return 结果
     */
    @Override
    public int deleteInfoProjectMonitorIndexById(Long id) {
        return infoProjectMonitorIndexMapper.deleteInfoProjectMonitorIndexById(id);
    }

    @Override
    public int uploadFiles(InfoProjectMonitorIndex infoProjectMonitorIndex) {
        Long id=infoProjectMonitorIndex.getId();
        //读取这个文件地址
        String fileUrl = infoProjectMonitorIndex.getReportUrl();
        String fileName=infoProjectMonitorIndex.getReportName();
        InfoProjectMonitorIndex infoProjectMonitorIndex1=infoProjectMonitorIndexMapper.selectInfoProjectMonitorIndexById(id);
        infoProjectMonitorIndex1.setReportUrl(fileUrl);
        infoProjectMonitorIndex1.setReportName(fileName);
        int i=infoProjectMonitorIndexMapper.updateInfoProjectMonitorIndex(infoProjectMonitorIndex1);
        return i;
    }
}
